package com.ruoyi.web.xxj.contoller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.xxj.domain.ProductOrder;
import com.ruoyi.web.xxj.service.IProductOrderService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 文创订单Controller
 *
 * @author ruoyi
 * @date 2024-02-23
 */
@Api(tags = "文创订单管理")
@RestController
@RequestMapping("/xxj/productOrder")
public class ProductOrderController extends BaseController {
    @Autowired
    private IProductOrderService productOrderService;

    /**
     * 查询文创订单列表
     */
    @ApiOperation("查询文创订单列表")
    @GetMapping("/list")
    public TableDataInfo<ProductOrder> list(ProductOrder productOrder) {
        startPage();
        List<ProductOrder> list = productOrderService.selectProductOrderList(productOrder);
        return getDataTable(list);
    }

    /**
     * 导出文创订单列表
     */
    @ApiOperation("导出文创订单列表")
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProductOrder productOrder) {
    	PageUtils.clearPage();
        List<ProductOrder> list = productOrderService.selectProductOrderList(productOrder);
        ExcelUtil<ProductOrder> util = new ExcelUtil<ProductOrder>(ProductOrder.class);
        util.exportExcel(response, list, "文创订单数据");
    }

    /**
     * 获取文创订单详细信息
     */
    @ApiOperation("获取文创订单详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(productOrderService.selectProductOrderById(id));
    }

    /**
     * 新增文创订单
     */
    @PostMapping
    public AjaxResult add(@RequestBody ProductOrder productOrder) {
        return toAjax(productOrderService.insertProductOrder(productOrder));
    }

    /**
     * 修改文创订单
     */
    @ApiOperation("修改文创订单")
    @PutMapping
    public AjaxResult edit(@RequestBody ProductOrder productOrder) {
        return toAjax(productOrderService.updateProductOrder(productOrder));
    }

    /**
     * 删除文创订单
     */
    @ApiOperation("删除文创订单")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(productOrderService.deleteProductOrderByIds(ids));
    }

}
